#ifndef __HL2ServerInfo_h__
#define __HL2ServerInfo_h__

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "ServerInfo.h"
#include "HL2ServerInfo.h"

using namespace std;

class HL2ServerInfo : public ServerInfo {
	private:

	protected:
		int sock;
		uint32_t challenge;
		uint32_t getChallenge(int timeout_sec, int timeout_usec);
		int openConnection();
		int closeConnection();
		int readMultiReply(int fd, char *buf, size_t buflen, int timeout_sec, int timeout_usec);
	public:
		virtual ~HL2ServerInfo();
		//HL2ServerInfo(ServerInfo &arg) {};
		HL2ServerInfo(HL2ServerInfo &arg);
		HL2ServerInfo(struct sockaddr_in *_addr);
		HL2ServerInfo(const char *_addr = "127.0.0.1", short port = 27015);

		//virtual HL2ServerInfo & operator=(const ServerInfo &arg);
		virtual HL2ServerInfo & operator=(const HL2ServerInfo &arg);

		virtual const struct sockaddr_in *getAddress() const;
		virtual const map<string, string> & getRules();
		virtual const map<string, string> & getAttributes();
		virtual bool update(int timeout_sec = 3, int timeout_usec = 0);
		virtual bool updateRules(int timeout_sec = 3, int timeout_usec = 0);

};

#endif
